package com.fly.consultant.tools;

import com.fly.consultant.pojo.Reservation;
import com.fly.consultant.service.ReservationService;
import dev.langchain4j.agent.tool.P;
import dev.langchain4j.agent.tool.Tool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Component
public class ReservationTool {
    @Autowired
    private ReservationService reservationService;

    @Tool("添加志愿指导服务预约")
    public void addReservation(
            @P("考生姓名") String name,
            @P("考生性别")String gender,
            @P("考生电话")String phone,
            @P("沟通时间，格式为：yyyy-MM-dd'T'HH:mm")String communicationTime,
            @P("考生所在省份")String province,
            @P("考生预估分数")Integer estimatedScore
    ) {
        Reservation reservation = new Reservation(null,name, gender, phone, LocalDateTime.parse(communicationTime), province, estimatedScore);
        reservationService.addReservation(reservation);
    }

    @Tool("根据考生电话查询考生预约详情")
    public Reservation getReservationByPhone(@P("考生电话") String phone) {
        return reservationService.getReservationByPhone(phone);
    }
}
